﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class GIANGDAY
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();
        

        private String MAGD, MALOP, MAMH, MAGV, LOAIGD;
        private int HOCKI, NAMHOC, SOTIETCHUAN;

        public String maGD
        {
            get { return MAGD; }
            set { MAGD = value; }
        }

        public String maLop
        {
            get { return MALOP; }
            set { MALOP = value; }
        }

        public String maMH
        {
            get { return MAMH; }
            set { MAMH = value; }
        }

        public String maGV
        {
            get { return MAGV; }
            set { MAGV = value; }
        }

        public String loaiGD
        {
            get { return LOAIGD; }
            set { LOAIGD = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public int hocki
        {
            get { return HOCKI; }
            set { HOCKI = value; }
        }

        public int namhoc
        {
            get { return NAMHOC; }
            set { NAMHOC = value; }
        }

        public int sotietchuan
        {
            get { return SOTIETCHUAN; }
            set { SOTIETCHUAN = value; }
        }

        public void hienthi_GiangDay(DataGridView dtgGiangDay)
        {
            String excuteString = "SELECT * FROM GIANGDAY";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgGiangDay.DataSource = dataTable;
        }

        public void them_GiangDay(GIANGDAY giangday)
        {
            String excuteString = "INSERT INTO GIANGDAY VALUES('" + giangday.maGD + "','"
                                                                 + giangday.maLop + "','"
                                                                 + giangday.maMH + "','"
                                                                 + giangday.maGV + "',"
                                                                 + giangday.hocki + ","
                                                                 + giangday.namhoc + ",'"
                                                                 + giangday.loaiGD + "',"
                                                                 + giangday.sotietchuan + ")";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_GiangDay(GIANGDAY giangday)
        {
            String excuteString = "UPDATE GIANGDAY SET MALOP ='" + giangday.maLop +
                                                 "', MAMH ='" + giangday.maMH +
                                                 "', MAGV ='" + giangday.maGV +
                                                 "', HOCKI =" + giangday.hocki +
                                                 ", NAMHOC=" + giangday.namhoc +
                                                 ", LOAIGD ='" + giangday.loaiGD +
                                                 "', SOTIETCHUAN =" + giangday.sotietchuan +
                                                 "WHERE MAGD ='" + giangday.maGD + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void xoa_GiangDay(String magiangday)
        {
            String excuteString = "DELETE FROM GIANGDAY WHERE MAGD ='" + magiangday + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }




    }
}
